{extend name="public:index"/} {block name="title"}{:sysconf('title')}{/block} {block name="content"}
<div class="whtop">
    <div class="top">
        <p class="p1">
            <a href="javascript:history.back(-1)"></a>
        </p>
        <p class="p2">实名认证</p>
        <p class="p3"></p>
    </div>
</div>
<div style="height:2rem;"></div>
<div class="zhu_ce1">
    <form id="certify">
        <div class="c-login-input">
            <div class="form-group">
                <label class="f16">姓名</label>
                <div class="pull-left">
                    <input name="true_name" placeholder="请输入姓名" value="{$info['true_name']}">
                </div>
            </div>
            <div class="form-group">
                <label class="f16">身份证号</label>
                <div class="pull-left">
                    <input type="number" name="card" placeholder="请输入身份证号" value="{$info['card']}">
                </div>
            </div>
            <div class="form-group">
                <label class="f16">手机号</label>
                <div class="pull-left">
                    <input type="number" name="mobile" placeholder="请输入手机号码" value="{$info['mobile']}">
                </div>
            </div>
            {if condition="$info['is_true_name'] neq 2"}
            <div class="form-group">
                <label class="f16">验证码</label>
                <div class="pull-left">
                    <input name="code" placeholder="请输入验证码" value="">
                    <div class="yanz"><input type="button" id="sendcode" value="获取验证码" /> </div>
                </div>
            </div>
            {/if}
            <div class="Next_">
                {if condition="$info['is_true_name'] eq 1"}
                <input style="outline:none;margin-top:2rem;background-color: #9c9c9c;" disabled type="button" value="已提交,待审核!"> {elseif condition="$info['is_true_name'] eq 2"}
                <input style="outline:none;margin-top:2rem;background-color: #9c9c9c;" disabled type="button" value="已认证"> {elseif condition="$info['is_true_name'] eq 3"}
                <input style="outline:none;margin-top:2rem;" id="submit" type="button" value="重新认证"> {else/}
                <input style="outline:none;margin-top:2rem;" id="submit" type="button" value="立即认证"> {/if}
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $("#sendcode").click(function() {
        var mobile = $("input[name=mobile]").val();
        var sendbtn = $(this);
        var mobilereg = /^((13|14|15|17|18)\d{9})$/;
        if (mobile == "" || !mobilereg.test(mobile)) {
            layer.msg("请输入正确的手机号码", {
                icon: 5
            });
            return false;
        }
        $.ajax({
            type: "POST",
            url: "{:url('Common/sendSms')}",
            data: {
                'mobile': mobile
            },
            dataType: "JSON",
            success: function(data) {
                if (data.code == 0) {
                    $("#sendcode").prop("disabled", true);
                    var tstart = 59;
                    var internow = setInterval(function() {
                        tstart--;
                        sendbtn.val(tstart + '秒后重新获取');
                        if (tstart <= 0) {
                            clearInterval(internow);
                            sendbtn.val('获取短信验证码');
                            $("#sendcode").prop("disabled", false);
                        }
                    }, 1000);
                } else {
                    layer.msg(data.msg);
                    $("#sendcode").prop("disabled", false);
                }
            },
            error: function() {
                layer.msg("网络延迟，发送失败");
                $("#sendcode").prop("disabled", false);
            }
        });
    });
    $("#submit").click(function() {
        var trueName = $("input[name=true_name]").val();
        var mobile = $("input[name=mobile]").val();
        var card = $("input[name=card]").val();
        var code = $("input[name=code]").val();
        if (trueName == '' && mobile == '' && card == '' && code == '') {
            layer.msg('请填写认证资料', {
                icon: 5
            });
            return false;
        }
        var obj = $(this);
        var goodsId = obj.data('id');
        $.ajax({
            url: "{:url('User/certify')}",
            type: "POST",
            data: {
                'trueName': trueName,
                'mobile': mobile,
                'card': card,
                'code': code
            },
            dataType: "JSON",
            success: function(data) {
                if (data.code == 0) {
                    layer.msg(data.msg, {
                        icon: 6
                    }, function() {
                        window.location.reload();
                    })
                } else {
                    layer.msg(data.msg, {
                        'icon': 5
                    });
                }
            }
        });
    })
</script>
{/block}